#include <QDir>
#include <QInputDialog>
#include <QMessageBox>

#include "hbot.h"
#include "profilemanagereditprofile.h"
#include "sdefs.h"
#include "xmlconfig.h"

CProfileManagerEditProfile::CProfileManagerEditProfile(const QString &profile, CProfileManager *parent): QDialog(parent), Ui::ProfileManagerEditProfile()
{
	setupUi(this);

	m_Parent = parent;
	m_Profile = profile;

	setWindowTitle(this->windowTitle() + " - " + m_Profile);

	/*
	 * Qt Connects
	 */

	// Primary Buttons

	connect(okButton, SIGNAL(clicked()), this, SLOT(ActionAccept()));
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
	connect(applyButton, SIGNAL(clicked()), this, SLOT(ActionApply()));

	// Battle.net Vectors

	/* Push these back before doing any checks as many checks require use of these vectors */

		// Enabled

	m_BNETCheckBoxes.push_back(checkBoxEnabled_1);
	m_BNETCheckBoxes.push_back(checkBoxEnabled_2);
	m_BNETCheckBoxes.push_back(checkBoxEnabled_3);
	m_BNETCheckBoxes.push_back(checkBoxEnabled_4);
	m_BNETCheckBoxes.push_back(checkBoxEnabled_5);
	m_BNETCheckBoxes.push_back(checkBoxEnabled_6);
	m_BNETCheckBoxes.push_back(checkBoxEnabled_7);
	m_BNETCheckBoxes.push_back(checkBoxEnabled_8);
	m_BNETCheckBoxes.push_back(checkBoxEnabled_9);
	m_BNETCheckBoxes.push_back(checkBoxEnabled_10);

		// Server

	m_BNETServersV.push_back(lineEditBattlenetServer_1);
	m_BNETServersV.push_back(lineEditBattlenetServer_2);
	m_BNETServersV.push_back(lineEditBattlenetServer_3);
	m_BNETServersV.push_back(lineEditBattlenetServer_4);
	m_BNETServersV.push_back(lineEditBattlenetServer_5);
	m_BNETServersV.push_back(lineEditBattlenetServer_6);
	m_BNETServersV.push_back(lineEditBattlenetServer_7);
	m_BNETServersV.push_back(lineEditBattlenetServer_8);
	m_BNETServersV.push_back(lineEditBattlenetServer_9);
	m_BNETServersV.push_back(lineEditBattlenetServer_10);

		// Server Alias

	m_BNETServerAliases.push_back(lineEditBattlenetServerAlias_1);
	m_BNETServerAliases.push_back(lineEditBattlenetServerAlias_2);
	m_BNETServerAliases.push_back(lineEditBattlenetServerAlias_3);
	m_BNETServerAliases.push_back(lineEditBattlenetServerAlias_4);
	m_BNETServerAliases.push_back(lineEditBattlenetServerAlias_5);
	m_BNETServerAliases.push_back(lineEditBattlenetServerAlias_6);
	m_BNETServerAliases.push_back(lineEditBattlenetServerAlias_7);
	m_BNETServerAliases.push_back(lineEditBattlenetServerAlias_8);
	m_BNETServerAliases.push_back(lineEditBattlenetServerAlias_9);
	m_BNETServerAliases.push_back(lineEditBattlenetServerAlias_10);

		// RoC CD-Key

	m_BNETRoCCDKeys.push_back(lineEditBattlenetRoCCDKey_1);
	m_BNETRoCCDKeys.push_back(lineEditBattlenetRoCCDKey_2);
	m_BNETRoCCDKeys.push_back(lineEditBattlenetRoCCDKey_3);
	m_BNETRoCCDKeys.push_back(lineEditBattlenetRoCCDKey_4);
	m_BNETRoCCDKeys.push_back(lineEditBattlenetRoCCDKey_5);
	m_BNETRoCCDKeys.push_back(lineEditBattlenetRoCCDKey_6);
	m_BNETRoCCDKeys.push_back(lineEditBattlenetRoCCDKey_7);
	m_BNETRoCCDKeys.push_back(lineEditBattlenetRoCCDKey_8);
	m_BNETRoCCDKeys.push_back(lineEditBattlenetRoCCDKey_9);
	m_BNETRoCCDKeys.push_back(lineEditBattlenetRoCCDKey_10);

		// TFT CD-Key

	m_BNETTFTCDKeys.push_back(lineEditBattlenetTFTCDKey_1);
	m_BNETTFTCDKeys.push_back(lineEditBattlenetTFTCDKey_2);
	m_BNETTFTCDKeys.push_back(lineEditBattlenetTFTCDKey_3);
	m_BNETTFTCDKeys.push_back(lineEditBattlenetTFTCDKey_4);
	m_BNETTFTCDKeys.push_back(lineEditBattlenetTFTCDKey_5);
	m_BNETTFTCDKeys.push_back(lineEditBattlenetTFTCDKey_6);
	m_BNETTFTCDKeys.push_back(lineEditBattlenetTFTCDKey_7);
	m_BNETTFTCDKeys.push_back(lineEditBattlenetTFTCDKey_8);
	m_BNETTFTCDKeys.push_back(lineEditBattlenetTFTCDKey_9);
	m_BNETTFTCDKeys.push_back(lineEditBattlenetTFTCDKey_10);

		// Language Code

	m_BNETLanguageCodes.push_back(spinBoxBattlenetLanguageCode_1);
	m_BNETLanguageCodes.push_back(spinBoxBattlenetLanguageCode_2);
	m_BNETLanguageCodes.push_back(spinBoxBattlenetLanguageCode_3);
	m_BNETLanguageCodes.push_back(spinBoxBattlenetLanguageCode_4);
	m_BNETLanguageCodes.push_back(spinBoxBattlenetLanguageCode_5);
	m_BNETLanguageCodes.push_back(spinBoxBattlenetLanguageCode_6);
	m_BNETLanguageCodes.push_back(spinBoxBattlenetLanguageCode_7);
	m_BNETLanguageCodes.push_back(spinBoxBattlenetLanguageCode_8);
	m_BNETLanguageCodes.push_back(spinBoxBattlenetLanguageCode_9);
	m_BNETLanguageCodes.push_back(spinBoxBattlenetLanguageCode_10);

		// Language Code Note

	m_BNETLanguageCodeNotes.push_back(labelBattlenetLanguageCodeNote_1);
	m_BNETLanguageCodeNotes.push_back(labelBattlenetLanguageCodeNote_2);
	m_BNETLanguageCodeNotes.push_back(labelBattlenetLanguageCodeNote_3);
	m_BNETLanguageCodeNotes.push_back(labelBattlenetLanguageCodeNote_4);
	m_BNETLanguageCodeNotes.push_back(labelBattlenetLanguageCodeNote_5);
	m_BNETLanguageCodeNotes.push_back(labelBattlenetLanguageCodeNote_6);
	m_BNETLanguageCodeNotes.push_back(labelBattlenetLanguageCodeNote_7);
	m_BNETLanguageCodeNotes.push_back(labelBattlenetLanguageCodeNote_8);
	m_BNETLanguageCodeNotes.push_back(labelBattlenetLanguageCodeNote_9);
	m_BNETLanguageCodeNotes.push_back(labelBattlenetLanguageCodeNote_10);

		// Language Code List

	m_BNETLanguageCodeLists.push_back(pushButtonBattlenetLanguageCode_1);
	m_BNETLanguageCodeLists.push_back(pushButtonBattlenetLanguageCode_2);
	m_BNETLanguageCodeLists.push_back(pushButtonBattlenetLanguageCode_3);
	m_BNETLanguageCodeLists.push_back(pushButtonBattlenetLanguageCode_4);
	m_BNETLanguageCodeLists.push_back(pushButtonBattlenetLanguageCode_5);
	m_BNETLanguageCodeLists.push_back(pushButtonBattlenetLanguageCode_6);
	m_BNETLanguageCodeLists.push_back(pushButtonBattlenetLanguageCode_7);
	m_BNETLanguageCodeLists.push_back(pushButtonBattlenetLanguageCode_8);
	m_BNETLanguageCodeLists.push_back(pushButtonBattlenetLanguageCode_9);
	m_BNETLanguageCodeLists.push_back(pushButtonBattlenetLanguageCode_10);

		// Country Code

	m_BNETCountryCodes.push_back(spinBoxBattlenetCountryCode_1);
	m_BNETCountryCodes.push_back(spinBoxBattlenetCountryCode_2);
	m_BNETCountryCodes.push_back(spinBoxBattlenetCountryCode_3);
	m_BNETCountryCodes.push_back(spinBoxBattlenetCountryCode_4);
	m_BNETCountryCodes.push_back(spinBoxBattlenetCountryCode_5);
	m_BNETCountryCodes.push_back(spinBoxBattlenetCountryCode_6);
	m_BNETCountryCodes.push_back(spinBoxBattlenetCountryCode_7);
	m_BNETCountryCodes.push_back(spinBoxBattlenetCountryCode_8);
	m_BNETCountryCodes.push_back(spinBoxBattlenetCountryCode_9);
	m_BNETCountryCodes.push_back(spinBoxBattlenetCountryCode_10);

		// Country Code Note

	m_BNETCountryCodeNotes.push_back(labelBattlenetCountryCodeNote_1);
	m_BNETCountryCodeNotes.push_back(labelBattlenetCountryCodeNote_2);
	m_BNETCountryCodeNotes.push_back(labelBattlenetCountryCodeNote_3);
	m_BNETCountryCodeNotes.push_back(labelBattlenetCountryCodeNote_4);
	m_BNETCountryCodeNotes.push_back(labelBattlenetCountryCodeNote_5);
	m_BNETCountryCodeNotes.push_back(labelBattlenetCountryCodeNote_6);
	m_BNETCountryCodeNotes.push_back(labelBattlenetCountryCodeNote_7);
	m_BNETCountryCodeNotes.push_back(labelBattlenetCountryCodeNote_8);
	m_BNETCountryCodeNotes.push_back(labelBattlenetCountryCodeNote_9);
	m_BNETCountryCodeNotes.push_back(labelBattlenetCountryCodeNote_10);

		// Country Code List

	m_BNETCountryCodeLists.push_back(pushButtonBattlenetCountryCode_1);
	m_BNETCountryCodeLists.push_back(pushButtonBattlenetCountryCode_2);
	m_BNETCountryCodeLists.push_back(pushButtonBattlenetCountryCode_3);
	m_BNETCountryCodeLists.push_back(pushButtonBattlenetCountryCode_4);
	m_BNETCountryCodeLists.push_back(pushButtonBattlenetCountryCode_5);
	m_BNETCountryCodeLists.push_back(pushButtonBattlenetCountryCode_6);
	m_BNETCountryCodeLists.push_back(pushButtonBattlenetCountryCode_7);
	m_BNETCountryCodeLists.push_back(pushButtonBattlenetCountryCode_8);
	m_BNETCountryCodeLists.push_back(pushButtonBattlenetCountryCode_9);
	m_BNETCountryCodeLists.push_back(pushButtonBattlenetCountryCode_10);

		// Username

	m_BNETUsernames.push_back(lineEditBattlenetUsername_1);
	m_BNETUsernames.push_back(lineEditBattlenetUsername_2);
	m_BNETUsernames.push_back(lineEditBattlenetUsername_3);
	m_BNETUsernames.push_back(lineEditBattlenetUsername_4);
	m_BNETUsernames.push_back(lineEditBattlenetUsername_5);
	m_BNETUsernames.push_back(lineEditBattlenetUsername_6);
	m_BNETUsernames.push_back(lineEditBattlenetUsername_7);
	m_BNETUsernames.push_back(lineEditBattlenetUsername_8);
	m_BNETUsernames.push_back(lineEditBattlenetUsername_9);
	m_BNETUsernames.push_back(lineEditBattlenetUsername_10);

		// Password

	m_BNETPasswords.push_back(lineEditBattlenetPassword_1);
	m_BNETPasswords.push_back(lineEditBattlenetPassword_2);
	m_BNETPasswords.push_back(lineEditBattlenetPassword_3);
	m_BNETPasswords.push_back(lineEditBattlenetPassword_4);
	m_BNETPasswords.push_back(lineEditBattlenetPassword_5);
	m_BNETPasswords.push_back(lineEditBattlenetPassword_6);
	m_BNETPasswords.push_back(lineEditBattlenetPassword_7);
	m_BNETPasswords.push_back(lineEditBattlenetPassword_8);
	m_BNETPasswords.push_back(lineEditBattlenetPassword_9);
	m_BNETPasswords.push_back(lineEditBattlenetPassword_10);

		// First Channel

	m_BNETFirstChannels.push_back(lineEditBattlenetFirstChannel_1);
	m_BNETFirstChannels.push_back(lineEditBattlenetFirstChannel_2);
	m_BNETFirstChannels.push_back(lineEditBattlenetFirstChannel_3);
	m_BNETFirstChannels.push_back(lineEditBattlenetFirstChannel_4);
	m_BNETFirstChannels.push_back(lineEditBattlenetFirstChannel_5);
	m_BNETFirstChannels.push_back(lineEditBattlenetFirstChannel_6);
	m_BNETFirstChannels.push_back(lineEditBattlenetFirstChannel_7);
	m_BNETFirstChannels.push_back(lineEditBattlenetFirstChannel_8);
	m_BNETFirstChannels.push_back(lineEditBattlenetFirstChannel_9);
	m_BNETFirstChannels.push_back(lineEditBattlenetFirstChannel_10);

		// Root Admin

	m_BNETRootAdmins.push_back(comboBoxBattlenetRootAdmins_1);
	m_BNETRootAdmins.push_back(comboBoxBattlenetRootAdmins_2);
	m_BNETRootAdmins.push_back(comboBoxBattlenetRootAdmins_3);
	m_BNETRootAdmins.push_back(comboBoxBattlenetRootAdmins_4);
	m_BNETRootAdmins.push_back(comboBoxBattlenetRootAdmins_5);
	m_BNETRootAdmins.push_back(comboBoxBattlenetRootAdmins_6);
	m_BNETRootAdmins.push_back(comboBoxBattlenetRootAdmins_7);
	m_BNETRootAdmins.push_back(comboBoxBattlenetRootAdmins_8);
	m_BNETRootAdmins.push_back(comboBoxBattlenetRootAdmins_9);
	m_BNETRootAdmins.push_back(comboBoxBattlenetRootAdmins_10);

		// Add RA

	m_BNETAddRAs.push_back(pushButtonBattlenetAddRA_1);
	m_BNETAddRAs.push_back(pushButtonBattlenetAddRA_2);
	m_BNETAddRAs.push_back(pushButtonBattlenetAddRA_3);
	m_BNETAddRAs.push_back(pushButtonBattlenetAddRA_4);
	m_BNETAddRAs.push_back(pushButtonBattlenetAddRA_5);
	m_BNETAddRAs.push_back(pushButtonBattlenetAddRA_6);
	m_BNETAddRAs.push_back(pushButtonBattlenetAddRA_7);
	m_BNETAddRAs.push_back(pushButtonBattlenetAddRA_8);
	m_BNETAddRAs.push_back(pushButtonBattlenetAddRA_9);
	m_BNETAddRAs.push_back(pushButtonBattlenetAddRA_10);

		// Remove RA

	m_BNETRemoveRAs.push_back(pushButtonBattlenetRemoveRA_1);
	m_BNETRemoveRAs.push_back(pushButtonBattlenetRemoveRA_2);
	m_BNETRemoveRAs.push_back(pushButtonBattlenetRemoveRA_3);
	m_BNETRemoveRAs.push_back(pushButtonBattlenetRemoveRA_4);
	m_BNETRemoveRAs.push_back(pushButtonBattlenetRemoveRA_5);
	m_BNETRemoveRAs.push_back(pushButtonBattlenetRemoveRA_6);
	m_BNETRemoveRAs.push_back(pushButtonBattlenetRemoveRA_7);
	m_BNETRemoveRAs.push_back(pushButtonBattlenetRemoveRA_8);
	m_BNETRemoveRAs.push_back(pushButtonBattlenetRemoveRA_9);
	m_BNETRemoveRAs.push_back(pushButtonBattlenetRemoveRA_10);

		// Command Trigger

	m_BNETCommandTriggers.push_back(lineEditBattlenetCommandTrigger_1);
	m_BNETCommandTriggers.push_back(lineEditBattlenetCommandTrigger_2);
	m_BNETCommandTriggers.push_back(lineEditBattlenetCommandTrigger_3);
	m_BNETCommandTriggers.push_back(lineEditBattlenetCommandTrigger_4);
	m_BNETCommandTriggers.push_back(lineEditBattlenetCommandTrigger_5);
	m_BNETCommandTriggers.push_back(lineEditBattlenetCommandTrigger_6);
	m_BNETCommandTriggers.push_back(lineEditBattlenetCommandTrigger_7);
	m_BNETCommandTriggers.push_back(lineEditBattlenetCommandTrigger_8);
	m_BNETCommandTriggers.push_back(lineEditBattlenetCommandTrigger_9);
	m_BNETCommandTriggers.push_back(lineEditBattlenetCommandTrigger_10);

		// Hold Friends

	m_BNETHoldFriends.push_back(checkBoxBattlenetHoldFriends_1);
	m_BNETHoldFriends.push_back(checkBoxBattlenetHoldFriends_2);
	m_BNETHoldFriends.push_back(checkBoxBattlenetHoldFriends_3);
	m_BNETHoldFriends.push_back(checkBoxBattlenetHoldFriends_4);
	m_BNETHoldFriends.push_back(checkBoxBattlenetHoldFriends_5);
	m_BNETHoldFriends.push_back(checkBoxBattlenetHoldFriends_6);
	m_BNETHoldFriends.push_back(checkBoxBattlenetHoldFriends_7);
	m_BNETHoldFriends.push_back(checkBoxBattlenetHoldFriends_8);
	m_BNETHoldFriends.push_back(checkBoxBattlenetHoldFriends_9);
	m_BNETHoldFriends.push_back(checkBoxBattlenetHoldFriends_10);

		// Hold Clan

	m_BNETHoldClans.push_back(checkBoxBattlenetHoldClan_1);
	m_BNETHoldClans.push_back(checkBoxBattlenetHoldClan_2);
	m_BNETHoldClans.push_back(checkBoxBattlenetHoldClan_3);
	m_BNETHoldClans.push_back(checkBoxBattlenetHoldClan_4);
	m_BNETHoldClans.push_back(checkBoxBattlenetHoldClan_5);
	m_BNETHoldClans.push_back(checkBoxBattlenetHoldClan_6);
	m_BNETHoldClans.push_back(checkBoxBattlenetHoldClan_7);
	m_BNETHoldClans.push_back(checkBoxBattlenetHoldClan_8);
	m_BNETHoldClans.push_back(checkBoxBattlenetHoldClan_9);
	m_BNETHoldClans.push_back(checkBoxBattlenetHoldClan_10);

		// Public Commands

	m_BNETPublicCommands.push_back(checkBoxBattlenetPublicCommands_1);
	m_BNETPublicCommands.push_back(checkBoxBattlenetPublicCommands_2);
	m_BNETPublicCommands.push_back(checkBoxBattlenetPublicCommands_3);
	m_BNETPublicCommands.push_back(checkBoxBattlenetPublicCommands_4);
	m_BNETPublicCommands.push_back(checkBoxBattlenetPublicCommands_5);
	m_BNETPublicCommands.push_back(checkBoxBattlenetPublicCommands_6);
	m_BNETPublicCommands.push_back(checkBoxBattlenetPublicCommands_7);
	m_BNETPublicCommands.push_back(checkBoxBattlenetPublicCommands_8);
	m_BNETPublicCommands.push_back(checkBoxBattlenetPublicCommands_9);
	m_BNETPublicCommands.push_back(checkBoxBattlenetPublicCommands_10);

		// PvPGN Connection

	m_BNETPvPGNConnections.push_back(checkBoxBattlenetPvPGN_1);
	m_BNETPvPGNConnections.push_back(checkBoxBattlenetPvPGN_2);
	m_BNETPvPGNConnections.push_back(checkBoxBattlenetPvPGN_3);
	m_BNETPvPGNConnections.push_back(checkBoxBattlenetPvPGN_4);
	m_BNETPvPGNConnections.push_back(checkBoxBattlenetPvPGN_5);
	m_BNETPvPGNConnections.push_back(checkBoxBattlenetPvPGN_6);
	m_BNETPvPGNConnections.push_back(checkBoxBattlenetPvPGN_7);
	m_BNETPvPGNConnections.push_back(checkBoxBattlenetPvPGN_8);
	m_BNETPvPGNConnections.push_back(checkBoxBattlenetPvPGN_9);
	m_BNETPvPGNConnections.push_back(checkBoxBattlenetPvPGN_10);

		// PvPGN Group Box

	m_BNETPvPGNGroupBoxes.push_back(groupBoxBattlenetPvPGN_1);
	m_BNETPvPGNGroupBoxes.push_back(groupBoxBattlenetPvPGN_2);
	m_BNETPvPGNGroupBoxes.push_back(groupBoxBattlenetPvPGN_3);
	m_BNETPvPGNGroupBoxes.push_back(groupBoxBattlenetPvPGN_4);
	m_BNETPvPGNGroupBoxes.push_back(groupBoxBattlenetPvPGN_5);
	m_BNETPvPGNGroupBoxes.push_back(groupBoxBattlenetPvPGN_6);
	m_BNETPvPGNGroupBoxes.push_back(groupBoxBattlenetPvPGN_7);
	m_BNETPvPGNGroupBoxes.push_back(groupBoxBattlenetPvPGN_8);
	m_BNETPvPGNGroupBoxes.push_back(groupBoxBattlenetPvPGN_9);
	m_BNETPvPGNGroupBoxes.push_back(groupBoxBattlenetPvPGN_10);

		// PvPGN Warcraft 3 Version

	m_BNETPvPGNW3Versions.push_back(lineEditBattlenetW3Version_1);
	m_BNETPvPGNW3Versions.push_back(lineEditBattlenetW3Version_2);
	m_BNETPvPGNW3Versions.push_back(lineEditBattlenetW3Version_3);
	m_BNETPvPGNW3Versions.push_back(lineEditBattlenetW3Version_4);
	m_BNETPvPGNW3Versions.push_back(lineEditBattlenetW3Version_5);
	m_BNETPvPGNW3Versions.push_back(lineEditBattlenetW3Version_6);
	m_BNETPvPGNW3Versions.push_back(lineEditBattlenetW3Version_7);
	m_BNETPvPGNW3Versions.push_back(lineEditBattlenetW3Version_8);
	m_BNETPvPGNW3Versions.push_back(lineEditBattlenetW3Version_9);
	m_BNETPvPGNW3Versions.push_back(lineEditBattlenetW3Version_10);
	
		// PvPGN EXE Version

	m_BNETPvPGNEXEVersions.push_back(lineEditBattlenetEXEVersion_1);
	m_BNETPvPGNEXEVersions.push_back(lineEditBattlenetEXEVersion_2);
	m_BNETPvPGNEXEVersions.push_back(lineEditBattlenetEXEVersion_3);
	m_BNETPvPGNEXEVersions.push_back(lineEditBattlenetEXEVersion_4);
	m_BNETPvPGNEXEVersions.push_back(lineEditBattlenetEXEVersion_5);
	m_BNETPvPGNEXEVersions.push_back(lineEditBattlenetEXEVersion_6);
	m_BNETPvPGNEXEVersions.push_back(lineEditBattlenetEXEVersion_7);
	m_BNETPvPGNEXEVersions.push_back(lineEditBattlenetEXEVersion_8);
	m_BNETPvPGNEXEVersions.push_back(lineEditBattlenetEXEVersion_9);
	m_BNETPvPGNEXEVersions.push_back(lineEditBattlenetEXEVersion_10);

		// PvPGN EXE Version Hash

	m_BNETPvPGNEXEVersionHashes.push_back(lineEditBattlenetEXEVersionHash_1);
	m_BNETPvPGNEXEVersionHashes.push_back(lineEditBattlenetEXEVersionHash_2);
	m_BNETPvPGNEXEVersionHashes.push_back(lineEditBattlenetEXEVersionHash_3);
	m_BNETPvPGNEXEVersionHashes.push_back(lineEditBattlenetEXEVersionHash_4);
	m_BNETPvPGNEXEVersionHashes.push_back(lineEditBattlenetEXEVersionHash_5);
	m_BNETPvPGNEXEVersionHashes.push_back(lineEditBattlenetEXEVersionHash_6);
	m_BNETPvPGNEXEVersionHashes.push_back(lineEditBattlenetEXEVersionHash_7);
	m_BNETPvPGNEXEVersionHashes.push_back(lineEditBattlenetEXEVersionHash_8);
	m_BNETPvPGNEXEVersionHashes.push_back(lineEditBattlenetEXEVersionHash_9);
	m_BNETPvPGNEXEVersionHashes.push_back(lineEditBattlenetEXEVersionHash_10);

		// PvPGN Password Hash Type

	m_BNETPvPGNPasswordHashTypes.push_back(lineEditBattlenetPasswordHashType_1);
	m_BNETPvPGNPasswordHashTypes.push_back(lineEditBattlenetPasswordHashType_2);
	m_BNETPvPGNPasswordHashTypes.push_back(lineEditBattlenetPasswordHashType_3);
	m_BNETPvPGNPasswordHashTypes.push_back(lineEditBattlenetPasswordHashType_4);
	m_BNETPvPGNPasswordHashTypes.push_back(lineEditBattlenetPasswordHashType_5);
	m_BNETPvPGNPasswordHashTypes.push_back(lineEditBattlenetPasswordHashType_6);
	m_BNETPvPGNPasswordHashTypes.push_back(lineEditBattlenetPasswordHashType_7);
	m_BNETPvPGNPasswordHashTypes.push_back(lineEditBattlenetPasswordHashType_8);
	m_BNETPvPGNPasswordHashTypes.push_back(lineEditBattlenetPasswordHashType_9);
	m_BNETPvPGNPasswordHashTypes.push_back(lineEditBattlenetPasswordHashType_10);

		// PvPGN Realm Name

	m_BNETPvPGNRealmNames.push_back(lineEditBattlenetPvPGNRealmName_1);
	m_BNETPvPGNRealmNames.push_back(lineEditBattlenetPvPGNRealmName_2);
	m_BNETPvPGNRealmNames.push_back(lineEditBattlenetPvPGNRealmName_3);
	m_BNETPvPGNRealmNames.push_back(lineEditBattlenetPvPGNRealmName_4);
	m_BNETPvPGNRealmNames.push_back(lineEditBattlenetPvPGNRealmName_5);
	m_BNETPvPGNRealmNames.push_back(lineEditBattlenetPvPGNRealmName_6);
	m_BNETPvPGNRealmNames.push_back(lineEditBattlenetPvPGNRealmName_7);
	m_BNETPvPGNRealmNames.push_back(lineEditBattlenetPvPGNRealmName_8);
	m_BNETPvPGNRealmNames.push_back(lineEditBattlenetPvPGNRealmName_9);
	m_BNETPvPGNRealmNames.push_back(lineEditBattlenetPvPGNRealmName_10);

		// PvPGN Max Message Length

	m_BNETPvPGNMaxMessageLengths.push_back(spinBoxBattlenetMaxMessageLength_1);
	m_BNETPvPGNMaxMessageLengths.push_back(spinBoxBattlenetMaxMessageLength_2);
	m_BNETPvPGNMaxMessageLengths.push_back(spinBoxBattlenetMaxMessageLength_3);
	m_BNETPvPGNMaxMessageLengths.push_back(spinBoxBattlenetMaxMessageLength_4);
	m_BNETPvPGNMaxMessageLengths.push_back(spinBoxBattlenetMaxMessageLength_5);
	m_BNETPvPGNMaxMessageLengths.push_back(spinBoxBattlenetMaxMessageLength_6);
	m_BNETPvPGNMaxMessageLengths.push_back(spinBoxBattlenetMaxMessageLength_7);
	m_BNETPvPGNMaxMessageLengths.push_back(spinBoxBattlenetMaxMessageLength_8);
	m_BNETPvPGNMaxMessageLengths.push_back(spinBoxBattlenetMaxMessageLength_9);
	m_BNETPvPGNMaxMessageLengths.push_back(spinBoxBattlenetMaxMessageLength_10);

		// Main Group Box

	m_BNETGroupBoxes.push_back(groupBox_1);
	m_BNETGroupBoxes.push_back(groupBox_2);
	m_BNETGroupBoxes.push_back(groupBox_3);
	m_BNETGroupBoxes.push_back(groupBox_4);
	m_BNETGroupBoxes.push_back(groupBox_5);
	m_BNETGroupBoxes.push_back(groupBox_6);
	m_BNETGroupBoxes.push_back(groupBox_7);
	m_BNETGroupBoxes.push_back(groupBox_8);
	m_BNETGroupBoxes.push_back(groupBox_9);
	m_BNETGroupBoxes.push_back(groupBox_10);

	// Profile Tab Values

	lineEditProfileName->setText(m_Profile);
	QString defaultProfile = g_HBot.GetXMLProfile()->GetDefaultProfile();

	if (defaultProfile == m_Profile)
	{
		checkBoxDefaultProfile->setChecked(true);
	}

	checkBoxRunOnOpen->setChecked(g_HBot.GetXMLProfile()->GetProfileValue("0", m_Profile, TAG_PROFILE_PROFILE, TAG_PROFILE_PROFILE_RUNONOPEN).toUInt());
	checkBoxUsingTFT->setChecked(g_HBot.GetXMLProfile()->GetProfileValue("1", m_Profile, TAG_PROFILE_PROFILE, TAG_PROFILE_PROFILE_USINGTFT).toUInt());

	if (!checkBoxUsingTFT->isChecked())
	{
		for (int i = 0; i < NUMBER_BNET_CONNECTIONS; ++i)
		{
			m_BNETTFTCDKeys[i]->setEnabled(false);
		}
	}

	int logMethod = g_HBot.GetXMLProfile()->GetProfileValue("1", m_Profile, TAG_PROFILE_PROFILE, TAG_PROFILE_PROFILE_LOGMETHOD).toUInt();

	if (logMethod == 0)
	{
		radioButtonLoggingDisabled->setChecked(true);
		lineEditLogFile->setEnabled(false);
	}
	else if (logMethod == 2)
	{
		radioButtonLoggingUnlocked->setChecked(true);
	}
	else
	{
		radioButtonLoggingLocked->setChecked(true);
	}

	lineEditLogFile->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_PROFILE, TAG_PROFILE_PROFILE_LOGFILE, ATTRIB_PROFILE_PROFILE_NAME));

	connect(lineEditProfileName, SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
	connect(checkBoxDefaultProfile, SIGNAL(stateChanged(int)), this, SLOT(ActionCheckBoxStateChanged(int)));
	connect(checkBoxRunOnOpen, SIGNAL(stateChanged(int)), this, SLOT(ActionCheckBoxStateChanged(int)));
	connect(checkBoxUsingTFT, SIGNAL(stateChanged(int)), this, SLOT(ActionCheckBoxTFTChanged(int)));
	connect(radioButtonLoggingDisabled, SIGNAL(clicked()), this, SLOT(ActionLogMethodChange()));
	connect(radioButtonLoggingLocked, SIGNAL(clicked()), this, SLOT(ActionLogMethodChange()));
	connect(radioButtonLoggingUnlocked, SIGNAL(clicked()), this, SLOT(ActionLogMethodChange()));
	connect(lineEditLogFile, SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));

	// Battle.net

	for (int i = 0; i < NUMBER_BNET_CONNECTIONS; ++i)
	{
		m_BNETCheckBoxes[i]->setChecked(g_HBot.GetXMLProfile()->GetProfileValue("0", m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_ENABLED).toUInt());
		m_BNETServersV[i]->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_SERVER, ATTRIB_PROFILE_BATTLENET_SERVER_NAME));
		m_BNETServerAliases[i]->setText(g_HBot.GetXMLProfile()->GetProfileValue(m_BNETServersV[i]->text(), m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_SERVER, ATTRIB_PROFILE_BATTLENET_SERVER_ALIAS));
		m_BNETRoCCDKeys[i]->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_CDKEY, ATTRIB_PROFILE_BATTLENET_CDKEY_ROC));
		m_BNETTFTCDKeys[i]->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_CDKEY, ATTRIB_PROFILE_BATTLENET_CDKEY_TFT));
		
		QLocale qLocale;

		m_BNETLanguageCodes[i]->setValue(g_HBot.GetXMLProfile()->GetProfileValue(QString::number(qLocale.language()), m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_LOCALE, ATTRIB_PROFILE_BATTLENET_LANGUAGE_CODE).toUInt());
		
		if (m_BNETLanguageCodes[i]->value() != qLocale.language())
		{
			m_BNETLanguageCodeNotes[i]->setText("<font color=#FF0000>Note: Language code is different from what HBot detects: (" + QString::number(qLocale.language()) + ").</font>");
		}
		
		m_BNETCountryCodes[i]->setValue(g_HBot.GetXMLProfile()->GetProfileValue(QString::number(qLocale.country()), m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_LOCALE, ATTRIB_PROFILE_BATTLENET_COUNTRY_CODE).toUInt());
		
		if (m_BNETCountryCodes[i]->value() != qLocale.country())
		{
			m_BNETCountryCodeNotes[i]->setText("<font color=#FF0000>Note: Country code is different from what HBot detects: (" + QString::number(qLocale.country()) + ").</font>");
		}

		m_BNETUsernames[i]->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_LOGIN, ATTRIB_PROFILE_BATTLENET_LOGIN_USERNAME));
		m_BNETPasswords[i]->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_LOGIN, ATTRIB_PROFILE_BATTLENET_LOGIN_PASSWORD));
		m_BNETFirstChannels[i]->setText(g_HBot.GetXMLProfile()->GetProfileValue("The Void", m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_CHANNEL, ATTRIB_PROFILE_BATTLENET_CHANNEL_NAME));

		int amount = g_HBot.GetXMLProfile()->GetProfileValue("0", m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_ROOTADMIN, ATTRIB_PROFILE_BATTLENET_ROOTADMIN_AMOUNT).toUInt();
		
		for (int j = 0; j < amount; ++j)
		{
			m_BNETRootAdmins[i]->addItem(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_ROOTADMIN, ATTRIB_PROFILE_BATTLENET_ROOTADMIN + QString::number(j + 1)));
		}

		if (!m_BNETRootAdmins[i]->count())
		{
			m_BNETRemoveRAs[i]->setEnabled(false);
		}

		m_BNETCommandTriggers[i]->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_COMMANDTRIGGER, ATTRIB_PROFILE_BATTLENET_COMMANDTRIGGER));
		m_BNETHoldFriends[i]->setChecked(g_HBot.GetXMLProfile()->GetProfileValue("1", m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_HOLDFRIENDS).toUInt());
		m_BNETHoldClans[i]->setChecked(g_HBot.GetXMLProfile()->GetProfileValue("1", m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_HOLDCLAN).toUInt());
		m_BNETPublicCommands[i]->setChecked(g_HBot.GetXMLProfile()->GetProfileValue("1", m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PUBLICCOMMANDS).toUInt());

		m_BNETPvPGNConnections[i]->setChecked(g_HBot.GetXMLProfile()->GetProfileValue("0", m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, ATTRIB_PROFILE_BATTLENET_PVPGN_ENABLED).toUInt());
		m_BNETPvPGNGroupBoxes[i]->setEnabled(m_BNETPvPGNConnections[i]->isChecked());
		m_BNETPvPGNW3Versions[i]->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, ATTRIB_PROFILE_BATTLENET_PVPGN_W3VERSION));
		m_BNETPvPGNEXEVersions[i]->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, ATTRIB_PROFILE_BATTLENET_PVPGN_EXEVERSION));
		m_BNETPvPGNEXEVersionHashes[i]->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, ATTRIB_PROFILE_BATTLENET_PVPGN_EXEVERSIONHASH));
		m_BNETPvPGNPasswordHashTypes[i]->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, ATTRIB_PROFILE_BATTLENET_PVPGN_PASSWORDHASHTYPE));
		m_BNETPvPGNRealmNames[i]->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, ATTRIB_PROFILE_BATTLENET_PVPGN_REALMNAME));
		m_BNETPvPGNMaxMessageLengths[i]->setValue(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, ATTRIB_PROFILE_BATTLENET_PVPGN_MAXMESSAGELENGTH).toUInt());

		m_BNETGroupBoxes[i]->setEnabled(m_BNETCheckBoxes[i]->isChecked());

		connect(m_BNETCheckBoxes[i], SIGNAL(stateChanged(int)), this, SLOT(ActionCheckBoxBNETStateChanged(int)));
		connect(m_BNETServersV[i], SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_BNETServerAliases[i], SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_BNETRoCCDKeys[i], SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_BNETTFTCDKeys[i], SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_BNETLanguageCodes[i], SIGNAL(valueChanged(int)), this, SLOT(ActionLanguageCodeChanged(int)));
		connect(m_BNETCountryCodes[i], SIGNAL(valueChanged(int)), this, SLOT(ActionCountryCodeChanged(int)));
		connect(m_BNETLanguageCodeLists[i], SIGNAL(clicked()), this, SLOT(ActionOpenLocaleCodeList()));
		connect(m_BNETCountryCodeLists[i], SIGNAL(clicked()), this, SLOT(ActionOpenLocaleCodeList()));
		connect(m_BNETUsernames[i], SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_BNETPasswords[i], SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_BNETFirstChannels[i], SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_BNETAddRAs[i], SIGNAL(clicked()), this, SLOT(ActionAddRootAdmin()));
		connect(m_BNETRemoveRAs[i], SIGNAL(clicked()), this, SLOT(ActionRemoveRootAdmin()));
		connect(m_BNETCommandTriggers[i], SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_BNETHoldFriends[i], SIGNAL(stateChanged(int)), this, SLOT(ActionCheckBoxStateChanged(int)));
		connect(m_BNETHoldClans[i], SIGNAL(stateChanged(int)), this, SLOT(ActionCheckBoxStateChanged(int)));
		connect(m_BNETPublicCommands[i], SIGNAL(stateChanged(int)), this, SLOT(ActionCheckBoxStateChanged(int)));
		connect(m_BNETPvPGNConnections[i], SIGNAL(stateChanged(int)), this, SLOT(ActionCheckBoxBNETPvPGNStateChanged(int)));
		connect(m_BNETPvPGNW3Versions[i], SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_BNETPvPGNEXEVersions[i], SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_BNETPvPGNEXEVersionHashes[i], SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_BNETPvPGNPasswordHashTypes[i], SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_BNETPvPGNRealmNames[i], SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_BNETPvPGNMaxMessageLengths[i], SIGNAL(valueChanged(QString)), this, SLOT(ActionApplyEnable(QString)));
	}

	// Database Tab Values

	comboBoxDatabaseTypes->insertItems(0, QStringList() << "MySQL" << "SQLite");
	comboBoxDatabaseTypes->setCurrentIndex(g_HBot.GetXMLProfile()->GetProfileValue("SQLite", m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_TYPE, ATTRIB_PROFILE_DATABASE_NAME) == "MySQL" ? 0 : 1);

	if (comboBoxDatabaseTypes->itemText(comboBoxDatabaseTypes->currentIndex()) == "MySQL")
	{
		m_DatabaseSQLiteHorizontalLayout = NULL;
		m_DatabaseSQLiteFileNameLabel = NULL;
		m_DatabaseSQLiteFileNameLineEdit = NULL;

		groupBoxDatabaseOptions->setTitle("MySQL Database Options");

		m_DatabaseSubGroupBoxLayout = new QVBoxLayout();
		m_DatabaseInfo = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseInfo->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop);
		m_DatabaseInfo->setWordWrap(true);
		m_DatabaseSubGroupBoxLayout->addWidget(m_DatabaseInfo);

		m_DatabaseMySQLHorizontalLayoutServer = new QHBoxLayout();
		m_DatabaseMySQLServerLabel = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseMySQLHorizontalLayoutServer->addWidget(m_DatabaseMySQLServerLabel);
		m_DatabaseMySQLServerLineEdit = new QLineEdit(groupBoxDatabaseOptions);
		m_DatabaseMySQLServerLineEdit->setMaxLength(40);
		m_DatabaseMySQLHorizontalLayoutServer->addWidget(m_DatabaseMySQLServerLineEdit);

		m_DatabaseMySQLHorizontalLayoutDatabase = new QHBoxLayout();
		m_DatabaseMySQLDatabaseLabel = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseMySQLHorizontalLayoutDatabase->addWidget(m_DatabaseMySQLDatabaseLabel);
		m_DatabaseMySQLDatabaseLineEdit = new QLineEdit(groupBoxDatabaseOptions);
		m_DatabaseMySQLDatabaseLineEdit->setMaxLength(40);
		m_DatabaseMySQLHorizontalLayoutDatabase->addWidget(m_DatabaseMySQLDatabaseLineEdit);

		m_DatabaseMySQLHorizontalLayoutUser = new QHBoxLayout();
		m_DatabaseMySQLUserLabel = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseMySQLHorizontalLayoutUser->addWidget(m_DatabaseMySQLUserLabel);
		m_DatabaseMySQLUserLineEdit = new QLineEdit(groupBoxDatabaseOptions);
		m_DatabaseMySQLUserLineEdit->setMaxLength(40);
		m_DatabaseMySQLHorizontalLayoutUser->addWidget(m_DatabaseMySQLUserLineEdit);

		m_DatabaseMySQLHorizontalLayoutPassword = new QHBoxLayout();
		m_DatabaseMySQLPasswordLabel = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseMySQLHorizontalLayoutPassword->addWidget(m_DatabaseMySQLPasswordLabel);
		m_DatabaseMySQLPasswordLineEdit = new QLineEdit(groupBoxDatabaseOptions);
		m_DatabaseMySQLPasswordLineEdit->setMaxLength(40);
		m_DatabaseMySQLPasswordLineEdit->setEchoMode(QLineEdit::Password);
		m_DatabaseMySQLHorizontalLayoutPassword->addWidget(m_DatabaseMySQLPasswordLineEdit);

		m_DatabaseMySQLHorizontalLayoutPort = new QHBoxLayout();
		m_DatabaseMySQLPortLabel = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseMySQLHorizontalLayoutPort->addWidget(m_DatabaseMySQLPortLabel);
		m_DatabaseMySQLPortSpinBox = new QSpinBox(groupBoxDatabaseOptions);
		m_DatabaseMySQLPortSpinBox->setMinimum(0);
		m_DatabaseMySQLPortSpinBox->setMaximum(65535);
		m_DatabaseMySQLHorizontalLayoutPort->addWidget(m_DatabaseMySQLPortSpinBox);
		m_DatabaseMySQLPortVerticalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
		m_DatabaseMySQLHorizontalLayoutPort->addItem(m_DatabaseMySQLPortVerticalSpacer);

		m_DatabaseSubGroupBoxLayout->addLayout(m_DatabaseMySQLHorizontalLayoutServer);
		m_DatabaseSubGroupBoxLayout->addLayout(m_DatabaseMySQLHorizontalLayoutDatabase);
		m_DatabaseSubGroupBoxLayout->addLayout(m_DatabaseMySQLHorizontalLayoutUser);
		m_DatabaseSubGroupBoxLayout->addLayout(m_DatabaseMySQLHorizontalLayoutPassword);
		m_DatabaseSubGroupBoxLayout->addLayout(m_DatabaseMySQLHorizontalLayoutPort);
		m_DatabaseVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
		m_DatabaseSubGroupBoxLayout->addItem(m_DatabaseVerticalSpacer);
		verticalLayoutGroupBox->addLayout(m_DatabaseSubGroupBoxLayout);

		m_DatabaseInfo->setText(DATABASE_MYSQL_INFO);

		m_DatabaseMySQLServerLabel->setText("Server:");
		m_DatabaseMySQLServerLineEdit->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, ATTRIB_PROFILE_DATABASE_MYSQL_SERVER));
		m_DatabaseMySQLServerLineEdit->setToolTip("This is the name of the MySQL server for the bot to connect\nto. It is recommended that the bot be on the same computer\nas the MySQL server so you can just use 'localhost' or\n'127.0.0.1' here to refer to the local computer. It is\npossible to target a different computer although you will\nprobably need to edit permission rights to successfully\naccess the MySQL server. There is no default value for this, so be sure to define\na server before opening this profile.");
		
		m_DatabaseMySQLDatabaseLabel->setText("Database:");
		m_DatabaseMySQLDatabaseLineEdit->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, ATTRIB_PROFILE_DATABASE_MYSQL_DATABASE));
		m_DatabaseMySQLDatabaseLineEdit->setToolTip("This is the name of the MySQL database that is located at the\nassigned MySQL server as defined above. There is no default\nvalue for this, so be sure to define a server before opening\nthis profile.");

		m_DatabaseMySQLUserLabel->setText("User:");
		m_DatabaseMySQLUserLineEdit->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, ATTRIB_PROFILE_DATABASE_MYSQL_USER));
		m_DatabaseMySQLUserLineEdit->setToolTip("This is the name of the MySQL user that is located in the\nMySQL database as defined above. There is no defaultvalue for\nthis, so be sure to define a server before opening this\nprofile.");

		m_DatabaseMySQLPasswordLabel->setText("Password:");
		m_DatabaseMySQLPasswordLineEdit->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, ATTRIB_PROFILE_DATABASE_MYSQL_PASSWORD));
		m_DatabaseMySQLPasswordLineEdit->setToolTip("This is the password of the MySQL user that is located in the\nMySQL database defined above.");

		m_DatabaseMySQLPortLabel->setText("Port:");
		m_DatabaseMySQLPortSpinBox->setValue(g_HBot.GetXMLProfile()->GetProfileValue("3306", m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, ATTRIB_PROFILE_DATABASE_MYSQL_PORT).toUInt());
		m_DatabaseMySQLPortSpinBox->setToolTip("This is the port that the bot will use to connect to the\nMySQL server. This value must be a valid port and therefore\nmust be between 1-65535. The default value for this is port\n3306.");

		connect(m_DatabaseMySQLServerLineEdit, SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_DatabaseMySQLDatabaseLineEdit, SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_DatabaseMySQLUserLineEdit, SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_DatabaseMySQLPasswordLineEdit, SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_DatabaseMySQLPortSpinBox, SIGNAL(valueChanged(QString)), this, SLOT(ActionApplyEnable(QString)));
	}
	else
	{
		m_DatabaseMySQLHorizontalLayoutServer = NULL;
		m_DatabaseMySQLServerLabel = NULL;
		m_DatabaseMySQLServerLineEdit = NULL;
		m_DatabaseMySQLHorizontalLayoutDatabase = NULL;
		m_DatabaseMySQLDatabaseLabel = NULL;
		m_DatabaseMySQLDatabaseLineEdit = NULL;
		m_DatabaseMySQLHorizontalLayoutUser = NULL;
		m_DatabaseMySQLUserLabel = NULL;
		m_DatabaseMySQLUserLineEdit = NULL;
		m_DatabaseMySQLHorizontalLayoutPassword = NULL;
		m_DatabaseMySQLPasswordLabel = NULL;
		m_DatabaseMySQLPasswordLineEdit = NULL;
		m_DatabaseMySQLHorizontalLayoutPort = NULL;
		m_DatabaseMySQLPortLabel = NULL;
		m_DatabaseMySQLPortSpinBox = NULL;
		m_DatabaseMySQLPortVerticalSpacer = NULL;

		groupBoxDatabaseOptions->setTitle("SQLite Database Options");

		m_DatabaseSubGroupBoxLayout = new QVBoxLayout();
		m_DatabaseInfo = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseInfo->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop);
		m_DatabaseInfo->setWordWrap(true);
		m_DatabaseSubGroupBoxLayout->addWidget(m_DatabaseInfo);
		m_DatabaseSQLiteHorizontalLayout = new QHBoxLayout();
		m_DatabaseSQLiteFileNameLabel = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseSQLiteHorizontalLayout->addWidget(m_DatabaseSQLiteFileNameLabel);
		m_DatabaseSQLiteFileNameLineEdit = new QLineEdit(groupBoxDatabaseOptions);
		m_DatabaseSQLiteFileNameLineEdit->setMaxLength(40);
		m_DatabaseSQLiteHorizontalLayout->addWidget(m_DatabaseSQLiteFileNameLineEdit);
		m_DatabaseSubGroupBoxLayout->addLayout(m_DatabaseSQLiteHorizontalLayout);
		m_DatabaseVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
		m_DatabaseSubGroupBoxLayout->addItem(m_DatabaseVerticalSpacer);
		verticalLayoutGroupBox->addLayout(m_DatabaseSubGroupBoxLayout);
		m_DatabaseInfo->setText(DATABASE_SQLITE_INFO);
		m_DatabaseSQLiteFileNameLabel->setText("Database File:");
		m_DatabaseSQLiteFileNameLineEdit->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_SQLITE, ATTRIB_PROFILE_DATABASE_SQLITE_FILENAME));
		m_DatabaseSQLiteFileNameLineEdit->setToolTip("This defines what file the bot will load and save information\nto during execution. The database file is located in the\nDatabase folder and must not have an empty filename. There is\nno default value for this, so be  sure to define a filename\nbefore opening this profile.");
		connect(m_DatabaseSQLiteFileNameLineEdit, SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
	}

	connect(comboBoxDatabaseTypes, SIGNAL(currentIndexChanged(int)), this, SLOT(ActionDatabaseTypeChanged(int)));
	
	okButton->setFocus();
}

CProfileManagerEditProfile::~CProfileManagerEditProfile()
{
	
}

void CProfileManagerEditProfile::ActionAddRootAdmin()
{
	bool ok;
	bool itemExists = false;
	int invalidUser = 0;
	QString user;

	do
	{
		if (itemExists)
		{
			user = QInputDialog::getText(this, tr("Add Root Admin"), tr("A user with that name already exists.\nRoot Admin Name:"), QLineEdit::Normal, QString(), &ok);
		}
		else if (invalidUser == 1)
		{
			user = QInputDialog::getText(this, tr("Add Root Admin"), tr("The root admin name must at least be 3 characters.\nRoot Admin Name:"), QLineEdit::Normal, QString(), &ok);
		}
		else if (invalidUser == 2)
		{
			user = QInputDialog::getText(this, tr("Add Root Admin"), tr("The root admin name must no more than 15 characters.\nRoot Admin Name:"), QLineEdit::Normal, QString(), &ok);
		}
		else
		{
			user = QInputDialog::getText(this, tr("Add Root Admin"), tr("Root Admin Name:"), QLineEdit::Normal, QString(), &ok);
		}

		if (!ok)
		{
			return;
		}

		if (m_BNETRootAdmins[tabWidgetBattlenet->currentIndex()]->findText(user, Qt::MatchFixedString) == -1)
		{
			itemExists = false;
		}
		else
		{
			itemExists = true;
		}

		if (user.count() < 3)
		{
			invalidUser = 1;
		}
		else if (user.count() > 15)
		{
			invalidUser = 2;
		}
		else
		{
			invalidUser = 0;
		}
	} while (user.isEmpty() || itemExists || invalidUser);

	m_BNETRootAdmins[tabWidgetBattlenet->currentIndex()]->addItem(user);
	m_BNETRootAdmins[tabWidgetBattlenet->currentIndex()]->setCurrentIndex(m_BNETRootAdmins[tabWidgetBattlenet->currentIndex()]->count() - 1);

	m_BNETRemoveRAs[tabWidgetBattlenet->currentIndex()]->setEnabled(true);

	ActionApplyEnable(QString::null);
}

void CProfileManagerEditProfile::ActionApply()
{
	if (ActionAccept(true))
	{
		applyButton->setEnabled(false);
	}
}

void CProfileManagerEditProfile::ActionApplyEnable(const QString &)
{
	applyButton->setEnabled(true);
}

void CProfileManagerEditProfile::ActionCheckBoxBNETPvPGNStateChanged(int state)
{
	m_BNETPvPGNGroupBoxes[tabWidgetBattlenet->currentIndex()]->setEnabled(state);
	ActionApplyEnable(QString::null);
}

void CProfileManagerEditProfile::ActionCheckBoxBNETStateChanged(int state)
{
	m_BNETGroupBoxes[tabWidgetBattlenet->currentIndex()]->setEnabled(state);
	ActionApplyEnable(QString::null);
}

void CProfileManagerEditProfile::ActionCheckBoxStateChanged(int state)
{
	ActionApplyEnable(QString::null);
}

void CProfileManagerEditProfile::ActionCheckBoxTFTChanged(int state)
{
	ActionApplyEnable(QString::null);

	for (int i = 0; i < NUMBER_BNET_CONNECTIONS; ++i)
	{
		m_BNETTFTCDKeys[i]->setEnabled(state);
	}
}

void CProfileManagerEditProfile::ActionCountryCodeChanged(int val)
{
	ActionApplyEnable(QString::null);

	QLocale qLocale;

	if (val != qLocale.country())
	{
		m_BNETCountryCodeNotes[tabWidgetBattlenet->currentIndex()]->setText("<font color=#FF0000>Note: Country code is different from what HBot detects: (" + QString::number(qLocale.country()) + ").</font>");
	}
	else
	{
		m_BNETCountryCodeNotes[tabWidgetBattlenet->currentIndex()]->clear();
	}
}

void CProfileManagerEditProfile::ActionLanguageCodeChanged(int val)
{
	ActionApplyEnable(QString::null);

	QLocale qLocale;

	if (val != qLocale.language())
	{
		m_BNETLanguageCodeNotes[tabWidgetBattlenet->currentIndex()]->setText("<font color=#FF0000>Note: Language code is different from what HBot detects: (" + QString::number(qLocale.language()) + ").</font>");
	}
	else
	{
		m_BNETLanguageCodeNotes[tabWidgetBattlenet->currentIndex()]->clear();
	}
}

void CProfileManagerEditProfile::ActionDatabaseTypeChanged(int index)
{
	ActionApplyEnable(QString::null);

	verticalLayoutGroupBox->removeItem(m_DatabaseSubGroupBoxLayout);
	delete m_DatabaseSubGroupBoxLayout;
	
	if (m_DatabaseInfo)
	{
		delete m_DatabaseInfo;
		m_DatabaseInfo = NULL;
	}

	if (m_DatabaseSQLiteFileNameLabel)
	{
		delete m_DatabaseSQLiteFileNameLabel;
		m_DatabaseSQLiteFileNameLabel = NULL;
	}

	if (m_DatabaseSQLiteFileNameLineEdit)
	{
		delete m_DatabaseSQLiteFileNameLineEdit;
		m_DatabaseSQLiteFileNameLineEdit = NULL;
	}

	if (m_DatabaseMySQLServerLabel)
	{
		delete m_DatabaseMySQLServerLabel;
		m_DatabaseMySQLServerLabel = NULL;
	}

	if (m_DatabaseMySQLServerLineEdit)
	{
		delete m_DatabaseMySQLServerLineEdit;
		m_DatabaseMySQLServerLineEdit = NULL;
	}

	if (m_DatabaseMySQLDatabaseLabel)
	{
		delete m_DatabaseMySQLDatabaseLabel;
		m_DatabaseMySQLDatabaseLabel = NULL;
	}

	if (m_DatabaseMySQLDatabaseLineEdit)
	{
		delete m_DatabaseMySQLDatabaseLineEdit;
		m_DatabaseMySQLDatabaseLineEdit = NULL;
	}

	if (m_DatabaseMySQLUserLabel)
	{
		delete m_DatabaseMySQLUserLabel;
		m_DatabaseMySQLUserLabel = NULL;
	}

	if (m_DatabaseMySQLUserLineEdit)
	{
		delete m_DatabaseMySQLUserLineEdit;
		m_DatabaseMySQLUserLineEdit = NULL;
	}

	if (m_DatabaseMySQLPasswordLabel)
	{
		delete m_DatabaseMySQLPasswordLabel;
		m_DatabaseMySQLPasswordLabel = NULL;
	}

	if (m_DatabaseMySQLPasswordLineEdit)
	{
		delete m_DatabaseMySQLPasswordLineEdit;
		m_DatabaseMySQLPasswordLineEdit = NULL;
	}

	if (m_DatabaseMySQLPortLabel)
	{
		delete m_DatabaseMySQLPortLabel;
		m_DatabaseMySQLPortLabel = NULL;
	}

	if (m_DatabaseMySQLPortSpinBox)
	{
		delete m_DatabaseMySQLPortSpinBox;
		m_DatabaseMySQLPortSpinBox = NULL;
	}

	m_DatabaseSubGroupBoxLayout = NULL;
	m_DatabaseVerticalSpacer = NULL;
	m_DatabaseMySQLPortVerticalSpacer = NULL;

	if (index == 0)
	{
		groupBoxDatabaseOptions->setTitle("MySQL Database Options");

		m_DatabaseSubGroupBoxLayout = new QVBoxLayout();
		m_DatabaseInfo = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseInfo->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop);
		m_DatabaseInfo->setWordWrap(true);
		m_DatabaseSubGroupBoxLayout->addWidget(m_DatabaseInfo);

		m_DatabaseMySQLHorizontalLayoutServer = new QHBoxLayout();
		m_DatabaseMySQLServerLabel = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseMySQLHorizontalLayoutServer->addWidget(m_DatabaseMySQLServerLabel);
		m_DatabaseMySQLServerLineEdit = new QLineEdit(groupBoxDatabaseOptions);
		m_DatabaseMySQLServerLineEdit->setMaxLength(40);
		m_DatabaseMySQLHorizontalLayoutServer->addWidget(m_DatabaseMySQLServerLineEdit);

		m_DatabaseMySQLHorizontalLayoutDatabase = new QHBoxLayout();
		m_DatabaseMySQLDatabaseLabel = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseMySQLHorizontalLayoutDatabase->addWidget(m_DatabaseMySQLDatabaseLabel);
		m_DatabaseMySQLDatabaseLineEdit = new QLineEdit(groupBoxDatabaseOptions);
		m_DatabaseMySQLDatabaseLineEdit->setMaxLength(40);
		m_DatabaseMySQLHorizontalLayoutDatabase->addWidget(m_DatabaseMySQLDatabaseLineEdit);

		m_DatabaseMySQLHorizontalLayoutUser = new QHBoxLayout();
		m_DatabaseMySQLUserLabel = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseMySQLHorizontalLayoutUser->addWidget(m_DatabaseMySQLUserLabel);
		m_DatabaseMySQLUserLineEdit = new QLineEdit(groupBoxDatabaseOptions);
		m_DatabaseMySQLUserLineEdit->setMaxLength(40);
		m_DatabaseMySQLHorizontalLayoutUser->addWidget(m_DatabaseMySQLUserLineEdit);

		m_DatabaseMySQLHorizontalLayoutPassword = new QHBoxLayout();
		m_DatabaseMySQLPasswordLabel = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseMySQLHorizontalLayoutPassword->addWidget(m_DatabaseMySQLPasswordLabel);
		m_DatabaseMySQLPasswordLineEdit = new QLineEdit(groupBoxDatabaseOptions);
		m_DatabaseMySQLPasswordLineEdit->setMaxLength(40);
		m_DatabaseMySQLPasswordLineEdit->setEchoMode(QLineEdit::Password);
		m_DatabaseMySQLHorizontalLayoutPassword->addWidget(m_DatabaseMySQLPasswordLineEdit);

		m_DatabaseMySQLHorizontalLayoutPort = new QHBoxLayout();
		m_DatabaseMySQLPortLabel = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseMySQLHorizontalLayoutPort->addWidget(m_DatabaseMySQLPortLabel);
		m_DatabaseMySQLPortSpinBox = new QSpinBox(groupBoxDatabaseOptions);
		m_DatabaseMySQLPortSpinBox->setMinimum(0);
		m_DatabaseMySQLPortSpinBox->setMaximum(65535);
		m_DatabaseMySQLHorizontalLayoutPort->addWidget(m_DatabaseMySQLPortSpinBox);
		m_DatabaseMySQLPortVerticalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
		m_DatabaseMySQLHorizontalLayoutPort->addItem(m_DatabaseMySQLPortVerticalSpacer);

		m_DatabaseSubGroupBoxLayout->addLayout(m_DatabaseMySQLHorizontalLayoutServer);
		m_DatabaseSubGroupBoxLayout->addLayout(m_DatabaseMySQLHorizontalLayoutDatabase);
		m_DatabaseSubGroupBoxLayout->addLayout(m_DatabaseMySQLHorizontalLayoutUser);
		m_DatabaseSubGroupBoxLayout->addLayout(m_DatabaseMySQLHorizontalLayoutPassword);
		m_DatabaseSubGroupBoxLayout->addLayout(m_DatabaseMySQLHorizontalLayoutPort);
		m_DatabaseVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
		m_DatabaseSubGroupBoxLayout->addItem(m_DatabaseVerticalSpacer);
		verticalLayoutGroupBox->addLayout(m_DatabaseSubGroupBoxLayout);

		m_DatabaseInfo->setText(DATABASE_MYSQL_INFO);

		m_DatabaseMySQLServerLabel->setText("Server:");
		m_DatabaseMySQLServerLineEdit->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, ATTRIB_PROFILE_DATABASE_MYSQL_SERVER));
		m_DatabaseMySQLServerLineEdit->setToolTip("This is the name of the MySQL server for the bot to connect\nto. It is recommended that the bot be on the same computer\nas the MySQL server so you can just use 'localhost' or\n'127.0.0.1' here to refer to the local computer. It is\npossible to target a different computer although you will\nprobably need to edit permission rights to successfully\naccess the MySQL server. There is no default value for this, so be sure to define\na server before opening this profile.");
		
		m_DatabaseMySQLDatabaseLabel->setText("Database:");
		m_DatabaseMySQLDatabaseLineEdit->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, ATTRIB_PROFILE_DATABASE_MYSQL_DATABASE));
		m_DatabaseMySQLDatabaseLineEdit->setToolTip("This is the name of the MySQL database that is located at the\nassigned MySQL server as defined above. Please note that the\ndatabase must exist and that the bot will not create the\ndatabase for you if it does not exist. There is no default\nvalue for this, so be sure to define a server before opening\nthis profile.");

		m_DatabaseMySQLUserLabel->setText("User:");
		m_DatabaseMySQLUserLineEdit->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, ATTRIB_PROFILE_DATABASE_MYSQL_USER));
		m_DatabaseMySQLUserLineEdit->setToolTip("This is the name of the MySQL user that is located in the\nMySQL database as defined above. There is no defaultvalue for\nthis, so be sure to define a server before opening this\nprofile.");

		m_DatabaseMySQLPasswordLabel->setText("Password:");
		m_DatabaseMySQLPasswordLineEdit->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, ATTRIB_PROFILE_DATABASE_MYSQL_PASSWORD));
		m_DatabaseMySQLPasswordLineEdit->setToolTip("This is the password of the MySQL user that is located in the\nMySQL database defined above.");

		m_DatabaseMySQLPortLabel->setText("Port:");
		m_DatabaseMySQLPortSpinBox->setValue(g_HBot.GetXMLProfile()->GetProfileValue("3306", m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, ATTRIB_PROFILE_DATABASE_MYSQL_PORT).toUInt());
		m_DatabaseMySQLPortSpinBox->setToolTip("This is the port that the bot will use to connect to the\nMySQL server. This value must be a valid port and therefore\nmust be between 1-65535. The default value for this is port\n3306.");

		connect(m_DatabaseMySQLServerLineEdit, SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_DatabaseMySQLDatabaseLineEdit, SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_DatabaseMySQLUserLineEdit, SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_DatabaseMySQLPasswordLineEdit, SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
		connect(m_DatabaseMySQLPortSpinBox, SIGNAL(valueChanged(QString)), this, SLOT(ActionApplyEnable(QString)));
	}
	else
	{
		groupBoxDatabaseOptions->setTitle("SQLite Database Options");

		m_DatabaseSubGroupBoxLayout = new QVBoxLayout();
		m_DatabaseInfo = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseInfo->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop);
		m_DatabaseInfo->setWordWrap(true);
		m_DatabaseSubGroupBoxLayout->addWidget(m_DatabaseInfo);
		m_DatabaseSQLiteHorizontalLayout = new QHBoxLayout();
		m_DatabaseSQLiteFileNameLabel = new QLabel(groupBoxDatabaseOptions);
		m_DatabaseSQLiteHorizontalLayout->addWidget(m_DatabaseSQLiteFileNameLabel);
		m_DatabaseSQLiteFileNameLineEdit = new QLineEdit(groupBoxDatabaseOptions);
		m_DatabaseSQLiteFileNameLineEdit->setMaxLength(40);
		m_DatabaseSQLiteHorizontalLayout->addWidget(m_DatabaseSQLiteFileNameLineEdit);
		m_DatabaseSubGroupBoxLayout->addLayout(m_DatabaseSQLiteHorizontalLayout);
		m_DatabaseVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
		m_DatabaseSubGroupBoxLayout->addItem(m_DatabaseVerticalSpacer);
		verticalLayoutGroupBox->addLayout(m_DatabaseSubGroupBoxLayout);
		m_DatabaseInfo->setText(DATABASE_SQLITE_INFO);
		m_DatabaseSQLiteFileNameLabel->setText("Database File:");
		m_DatabaseSQLiteFileNameLineEdit->setText(g_HBot.GetXMLProfile()->GetProfileValue(QString::null, m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_SQLITE, ATTRIB_PROFILE_DATABASE_SQLITE_FILENAME));
		m_DatabaseSQLiteFileNameLineEdit->setToolTip("This defines what file the bot will load and save information\nto during execution. The database file is located in the\nDatabase folder and must not have an empty filename. There is\nno default value for this, so be  sure to define a filename\nbefore opening this profile.");
		connect(m_DatabaseSQLiteFileNameLineEdit, SIGNAL(textEdited(QString)), this, SLOT(ActionApplyEnable(QString)));
	}
}

void CProfileManagerEditProfile::ActionLogMethodChange()
{
	QRadioButton *button = (QRadioButton *) sender();

	if (button->text() == "Logging Disabled")
	{
		lineEditLogFile->setEnabled(false);
	}
	else
	{
		lineEditLogFile->setEnabled(true);
	}

	ActionApplyEnable();
}

void CProfileManagerEditProfile::ActionOpenLocaleCodeList()
{
	QPushButton *button = (QPushButton *) sender();
	bool lang;

	if (button->text() == "Language Code List")
	{
		lang = true;
	}
	else
	{
		lang = false;
	}

	CLocale locale(lang, this);
	locale.exec();
}

void CProfileManagerEditProfile::ActionRemoveRootAdmin()
{
	m_BNETRootAdmins[tabWidgetBattlenet->currentIndex()]->removeItem(m_BNETRootAdmins[tabWidgetBattlenet->currentIndex()]->currentIndex());

	if (!m_BNETRootAdmins[tabWidgetBattlenet->currentIndex()]->count())
	{
		m_BNETRemoveRAs[tabWidgetBattlenet->currentIndex()]->setEnabled(false);
	}

	ActionApplyEnable(QString::null);
}

bool CProfileManagerEditProfile::ActionAccept(bool apply)
{
	if (applyButton->isEnabled())
	{
		// This saving process can take up to 3-4 seconds. It took 2 seconds for me on Intel Core i5 760 @ 2.80 GHz (quad-core)

		// Profile Tab Values

		// Change Profile Name

		QString profileName = lineEditProfileName->text();

		if (profileName.compare(m_Profile, profileName, Qt::CaseInsensitive))
		{
			if (!m_Parent->listProfileManager->findItems(profileName, Qt::MatchFixedString).empty())
			{		
				QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr("Field <b>Profile::Profile Name</b>'s name has already been taken. Choose a different profile name."), QMessageBox::Ok);
				return false;
			}

			if (profileName.isEmpty())
			{
				QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr("Field <b>Profile::Profile Name</b> must at least be one character long."), QMessageBox::Ok);
				return false;
			}
			else if (profileName.startsWith(" "))
			{
				QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr("Field <b>Profile::Profile Name</b> must start with an alphanumeric character."), QMessageBox::Ok);
				return false;
			}
			else if (profileName.endsWith(" "))
			{
				QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr("Field <b>Profile::Profile Name</b> must end with an alphanumeric character."), QMessageBox::Ok);
				return false;
			}
			else if (g_HBot.ContainsInvalidCharacters(profileName))
			{
				QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr("Field <b>Profile::Profile Name</b> must not contain any of the following characters:<br>\\ / : * ? \" &#60; &#62; |"), QMessageBox::Ok);
				return false;
			}
		}

		if (m_Profile != profileName)
		{
			if (g_HBot.GetCurrentProfile() != m_Profile)
			{
				QDir dir;

				if (!dir.exists(QDir::currentPath() + "/Data/Profiles/" + m_Profile))
				{
					g_HBot.CreateProfileDirectory(profileName);
				}
				else
				{
					dir.rename(QDir::currentPath() + "/Data/Profiles/" + m_Profile, QDir::currentPath() + "/Data/Profiles/" + profileName);
				}

				QList<QAction *> profiles = g_HBot.GetMenuSelectProfile()->actions();

				for (int i = 0; i < profiles.size(); ++i)
				{
					if (profiles[i]->text() == m_Profile)
					{
						profiles[i]->setText(profileName);

						break;
					}
				}
		
				g_HBot.GetXMLProfile()->ChangeProfileName(m_Profile, profileName);
				QList<QListWidgetItem *> item = m_Parent->listProfileManager->findItems(m_Profile, Qt::MatchFixedString);

				if ((!g_HBot.GetXMLProfile()->GetErrorXML()) && (!item.empty()))
				{
					item[0]->setText(profileName);
					m_Profile = profileName;
				}
			}
			else
			{
				QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr("Field <b>Profile::Profile Name</b> cannot be edited while the profile is open."), QMessageBox::Ok);
				return false;
			}
		}

		// Set Default Value

		if (checkBoxDefaultProfile->isChecked())
		{
			g_HBot.GetXMLProfile()->SetDefaultProfile(m_Profile);
		}
		else
		{
			QString defaultProfile = g_HBot.GetXMLProfile()->GetDefaultProfile();

			if (defaultProfile == m_Profile)
			{
				g_HBot.GetXMLProfile()->SetDefaultProfile(QString::null);
			}
		}

		// Set Run On Open

		g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_PROFILE, TAG_PROFILE_PROFILE_RUNONOPEN, checkBoxRunOnOpen->isChecked() ? "1" : "0");

		// Set Using TFT (The Frozen Throne)

		g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_PROFILE, TAG_PROFILE_PROFILE_USINGTFT, checkBoxUsingTFT->isChecked() ? "1" : "0");

		// Set Logging Options

		int logMethod;
	
		if (radioButtonLoggingDisabled->isChecked())
		{
			logMethod = 0;
		}
		else if (radioButtonLoggingUnlocked->isChecked())
		{
			logMethod = 2;
		}
		else
		{
			logMethod = 1;
		}

		g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_PROFILE, TAG_PROFILE_PROFILE_LOGMETHOD, QString::number(logMethod));
	
		if (logMethod != 0)
		{
			if (g_HBot.ContainsInvalidCharacters(lineEditLogFile->text()))
			{
				QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr("Field <b>Profile::Log File</b> must not contain any of the following characters:<br>\\ / : * ? \" &#60; &#62; |"), QMessageBox::Ok);
				return false;
			}
			else
			{
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_PROFILE, TAG_PROFILE_PROFILE_LOGFILE, lineEditLogFile->text(), ATTRIB_PROFILE_PROFILE_NAME);
			}
		}
	
		// Battle.net Tab Values

		for (int i = 0; i < NUMBER_BNET_CONNECTIONS; ++i)
		{
			g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_ENABLED, m_BNETCheckBoxes[i]->isChecked() ? "1" : "0");

			if (m_BNETCheckBoxes[i]->isChecked())
			{
				if (m_BNETServersV[i]->text().isEmpty())
				{
					QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::Server</b> must at least be one character long.").toUtf8()), QMessageBox::Ok);
					return false;
				}
				else
				{
					g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_SERVER, m_BNETServersV[i]->text(), ATTRIB_PROFILE_BATTLENET_SERVER_NAME);
				}

				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_SERVER, m_BNETServerAliases[i]->text(), ATTRIB_PROFILE_BATTLENET_SERVER_ALIAS);

				if (m_BNETRoCCDKeys[i]->text().count() != 26)
				{
					QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::Reign of Chaos CD-Key</b> must be 26 characters long.").toUtf8()), QMessageBox::Ok);
					return false;
				}

				for (int j = 0; j < 26; ++j)
				{
					if (!m_BNETRoCCDKeys[i]->text()[j].isLetterOrNumber())
					{
						QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::Reign of Chaos CD-Key</b> must contain only alphanumerical characters.").toUtf8()), QMessageBox::Ok);
						return false;
					}
				}

				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_CDKEY, m_BNETRoCCDKeys[i]->text(), ATTRIB_PROFILE_BATTLENET_CDKEY_ROC);

				if (checkBoxUsingTFT->isChecked())
				{
					if (m_BNETTFTCDKeys[i]->text().count() != 26)
					{
						QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::The Frozen Throne CD-Key</b> must be 26 characters long.").toUtf8()), QMessageBox::Ok);
						return false;
					}

					for (int j = 0; j < 26; ++j)
					{
						if (!m_BNETTFTCDKeys[i]->text()[j].isLetterOrNumber())
						{
							QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::The Frozen Throne CD-Key</b> must contain only alphanumerical characters.").toUtf8()), QMessageBox::Ok);
							return false;
						}
					}
				}

				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_CDKEY, m_BNETTFTCDKeys[i]->text(), ATTRIB_PROFILE_BATTLENET_CDKEY_TFT);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_LOCALE, QString::number(m_BNETLanguageCodes[i]->value()), ATTRIB_PROFILE_BATTLENET_LANGUAGE_CODE);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_LOCALE, QString::number(m_BNETCountryCodes[i]->value()), ATTRIB_PROFILE_BATTLENET_COUNTRY_CODE);
		
				if (m_BNETUsernames[i]->text().count() < 3)
				{
					QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::Username</b> must at least be three characters long.").toUtf8()), QMessageBox::Ok);
					return false;
				}
				else
				{
					g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_LOGIN, m_BNETUsernames[i]->text(), ATTRIB_PROFILE_BATTLENET_LOGIN_USERNAME);
				}

				if (m_BNETPasswords[i]->text().count() < 3)
				{
					QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::Password</b> must at least be three characters long.").toUtf8()), QMessageBox::Ok);
					return false;
				}
				else
				{
					g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_LOGIN, m_BNETPasswords[i]->text(), ATTRIB_PROFILE_BATTLENET_LOGIN_PASSWORD);
				}

				if (m_BNETFirstChannels[i]->text().isEmpty())
				{
					QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::First Channel</b> must at least be one character long.").toUtf8()), QMessageBox::Ok);
					return false;
				}
				else
				{
					g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_CHANNEL, m_BNETFirstChannels[i]->text(), ATTRIB_PROFILE_BATTLENET_CHANNEL_NAME);
				}

				int amount = m_BNETRootAdmins[i]->count();

				for (int j = 0; j < amount; ++j)
				{
					QString user = m_BNETRootAdmins[i]->itemText(j);

					if (!user.isEmpty() && user.count() > 2 && user.count() < 16)
					{
						g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_ROOTADMIN, user, ATTRIB_PROFILE_BATTLENET_ROOTADMIN + QString::number(j + 1));
					}
				}

				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_ROOTADMIN, QString::number(amount), ATTRIB_PROFILE_BATTLENET_ROOTADMIN_AMOUNT);
		
				if (m_BNETCommandTriggers[i]->text().isEmpty())
				{
					QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::Server Command Trigger</b> must at least be one character long.").toUtf8()), QMessageBox::Ok);
					return false;
				}
				else if (m_BNETCommandTriggers[i]->text() == "/")
				{
					QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::Server Command Trigger</b> must not be the character:\n/").toUtf8()), QMessageBox::Ok);
					return false;
				}
				else
				{
					g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_COMMANDTRIGGER, m_BNETCommandTriggers[i]->text(), ATTRIB_PROFILE_BATTLENET_COMMANDTRIGGER);
				}

				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_HOLDFRIENDS, m_BNETHoldFriends[i]->isChecked() ? "1" : "0");
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_HOLDCLAN, m_BNETHoldClans[i]->isChecked() ? "1" : "0");
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PUBLICCOMMANDS, m_BNETPublicCommands[i]->isChecked() ? "1" : "0");
	
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, QString::number(m_BNETPvPGNConnections[i]->isChecked()), ATTRIB_PROFILE_BATTLENET_PVPGN_ENABLED);
		
				if (m_BNETPvPGNConnections[i]->isChecked())
				{
					if (m_BNETPvPGNW3Versions[i]->text().isEmpty())
					{
						QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::Warcraft 3 Version</b> must at least be one character long.").toUtf8()), QMessageBox::Ok);
						return false;
					}
					else
					{
						g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNW3Versions[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_W3VERSION);
					}

					if (m_BNETPvPGNEXEVersions[i]->text().isEmpty())
					{
						QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::EXE Version</b> must at least be one character long.").toUtf8()), QMessageBox::Ok);
						return false;
					}
					else
					{
						g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNEXEVersions[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_EXEVERSION);
					}

					if (m_BNETPvPGNEXEVersionHashes[i]->text().isEmpty())
					{
						QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::EXE Version Hash</b> must at least be one character long.").toUtf8()), QMessageBox::Ok);
						return false;
					}
					else
					{
						g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNEXEVersionHashes[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_EXEVERSIONHASH);
					}

					if (m_BNETPvPGNPasswordHashTypes[i]->text().isEmpty())
					{
						QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::Password Hash Type</b> must at least be one character long.").toUtf8()), QMessageBox::Ok);
						return false;
					}
					else
					{
						g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNPasswordHashTypes[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_PASSWORDHASHTYPE);
					}

					if (m_BNETPvPGNRealmNames[i]->text().isEmpty())
					{
						QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr(QString("Field <b>Battle.net-" + QString::number(i + 1) + "::PvPGN Realm Name</b> must at least be one character long.").toUtf8()), QMessageBox::Ok);
						return false;
					}
					else
					{
						g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNRealmNames[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_REALMNAME);
					}

					g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, QString::number(m_BNETPvPGNMaxMessageLengths[i]->value()), ATTRIB_PROFILE_BATTLENET_PVPGN_MAXMESSAGELENGTH);
				}
				else
				{
					g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNW3Versions[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_W3VERSION);
					g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNEXEVersions[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_EXEVERSION);
					g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNEXEVersionHashes[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_EXEVERSIONHASH);
					g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNPasswordHashTypes[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_PASSWORDHASHTYPE);
					g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNRealmNames[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_REALMNAME);
					g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, QString::number(m_BNETPvPGNMaxMessageLengths[i]->value()), ATTRIB_PROFILE_BATTLENET_PVPGN_MAXMESSAGELENGTH);
				}
			}
			else
			{
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_SERVER, m_BNETServersV[i]->text(), ATTRIB_PROFILE_BATTLENET_SERVER_NAME);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_SERVER, m_BNETServerAliases[i]->text(), ATTRIB_PROFILE_BATTLENET_SERVER_ALIAS);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_CDKEY, m_BNETRoCCDKeys[i]->text(), ATTRIB_PROFILE_BATTLENET_CDKEY_ROC);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_CDKEY, m_BNETTFTCDKeys[i]->text(), ATTRIB_PROFILE_BATTLENET_CDKEY_TFT);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_LOCALE, QString::number(m_BNETLanguageCodes[i]->value()), ATTRIB_PROFILE_BATTLENET_LANGUAGE_CODE);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_LOCALE, QString::number(m_BNETCountryCodes[i]->value()), ATTRIB_PROFILE_BATTLENET_COUNTRY_CODE);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_LOGIN, m_BNETUsernames[i]->text(), ATTRIB_PROFILE_BATTLENET_LOGIN_USERNAME);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_LOGIN, m_BNETPasswords[i]->text(), ATTRIB_PROFILE_BATTLENET_LOGIN_PASSWORD);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_CHANNEL, m_BNETFirstChannels[i]->text(), ATTRIB_PROFILE_BATTLENET_CHANNEL_NAME);

				int amount = m_BNETRootAdmins[i]->count();

				for (int j = 0; j < amount; ++j)
				{
					QString user = m_BNETRootAdmins[i]->itemText(j);

					if (!user.isEmpty() && user.count() > 2 && user.count() < 16)
					{
						g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_ROOTADMIN, user, ATTRIB_PROFILE_BATTLENET_ROOTADMIN + QString::number(j + 1));
					}
				}

				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_ROOTADMIN, QString::number(amount), ATTRIB_PROFILE_BATTLENET_ROOTADMIN_AMOUNT);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_COMMANDTRIGGER, m_BNETCommandTriggers[i]->text(), ATTRIB_PROFILE_BATTLENET_COMMANDTRIGGER);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_HOLDFRIENDS, m_BNETHoldFriends[i]->isChecked() ? "1" : "0");
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_HOLDCLAN, m_BNETHoldClans[i]->isChecked() ? "1" : "0");
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PUBLICCOMMANDS, m_BNETPublicCommands[i]->isChecked() ? "1" : "0");
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, QString::number(m_BNETPvPGNConnections[i]->isChecked()), ATTRIB_PROFILE_BATTLENET_PVPGN_ENABLED);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNW3Versions[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_W3VERSION);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNEXEVersions[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_EXEVERSION);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNEXEVersionHashes[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_EXEVERSIONHASH);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNPasswordHashTypes[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_PASSWORDHASHTYPE);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, m_BNETPvPGNRealmNames[i]->text(), ATTRIB_PROFILE_BATTLENET_PVPGN_REALMNAME);
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_BATTLENET + QString::number(i + 1), TAG_PROFILE_BATTLENET_PVPGN, QString::number(m_BNETPvPGNMaxMessageLengths[i]->value()), ATTRIB_PROFILE_BATTLENET_PVPGN_MAXMESSAGELENGTH);
			}
		}

		// Database Tab Values

		g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_TYPE, (comboBoxDatabaseTypes->currentIndex() == 0 ? "MySQL" : "SQLite3"), ATTRIB_PROFILE_DATABASE_NAME);
	
		if (comboBoxDatabaseTypes->currentText() == "SQLite")
		{
			if (m_DatabaseSQLiteFileNameLineEdit->text().isEmpty())
			{
				QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr("Field <b>Database::Database File</b> must at least be one character long."), QMessageBox::Ok);
				return false;
			}
			else if (g_HBot.ContainsInvalidCharacters(m_DatabaseSQLiteFileNameLineEdit->text()))
			{
				QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr("Field <b>Database::Database File</b> must not contain any of the following characters:<br>\\ / : * ? \" &#60; &#62; |"), QMessageBox::Ok);
				return false;
			}
			else
			{
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_SQLITE, m_DatabaseSQLiteFileNameLineEdit->text(), ATTRIB_PROFILE_DATABASE_SQLITE_FILENAME);	
			}
		}
		else
		{
			if (m_DatabaseMySQLServerLineEdit->text().isEmpty())
			{
				QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr("Field <b>Database::Server</b> must at least be one character long."), QMessageBox::Ok);
				return false;
			}
			else
			{
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, m_DatabaseMySQLServerLineEdit->text(), ATTRIB_PROFILE_DATABASE_MYSQL_SERVER);
			}

			if (m_DatabaseMySQLDatabaseLineEdit->text().isEmpty())
			{
				QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr("Field <b>Database::Database</b> must at least be one character long."), QMessageBox::Ok);
				return false;
			}
			else
			{
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, m_DatabaseMySQLDatabaseLineEdit->text(), ATTRIB_PROFILE_DATABASE_MYSQL_DATABASE);
			}

			if (m_DatabaseMySQLUserLineEdit->text().isEmpty())
			{
				QMessageBox::information(this, tr("Profile Manager: Edit Profile"), tr("Field <b>Database::User</b> must at least be one character long."), QMessageBox::Ok);
				return false;
			}
			else
			{
				g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, m_DatabaseMySQLUserLineEdit->text(), ATTRIB_PROFILE_DATABASE_MYSQL_USER);
			}
		
			g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, m_DatabaseMySQLPasswordLineEdit->text(), ATTRIB_PROFILE_DATABASE_MYSQL_PASSWORD);
			g_HBot.GetXMLProfile()->SetProfileValue(m_Profile, TAG_PROFILE_DATABASE, TAG_PROFILE_DATABASE_MYSQL, QString::number(m_DatabaseMySQLPortSpinBox->value()), ATTRIB_PROFILE_DATABASE_MYSQL_PORT);
		}
	}

	if (!apply)
	{
		this->close();
	}

	return true;
}

CLocale::CLocale(bool lang, CProfileManagerEditProfile *parent)
{
	setupUi(this);
	
	QLocale qLocale;
	labelLanguageNote->setText("Detected language: " + QLocale::languageToString(qLocale.language()) + " - Code: " + QString::number(qLocale.language()));
	labelCountryNote->setText("Detected country: " + QLocale::countryToString(qLocale.country()) + " - Code: " + QString::number(qLocale.country()));

	if (!lang)
	{
		tabWidget->setCurrentIndex(1);
	}
}

CLocale::~CLocale()
{

}
